<?php
namespace Common\Util;
use Think\Controller;

class makeHTML extends  Controller
{

    function ByGroupId($group_id) {}

     function ByGroupId2($group_id) {

        $info = M('Live')->where(array('group_id' => $group_id,'z_status'=>array('in',array(1,2))))->order('id DESC')->select();
        if($info) {
            $this->assign('info', $info);
            $rootPath = './Html/';
            $userFloder = date('Ymd', $info[0]['create_time']);
            if(!is_dir($rootPath . $userFloder))
                @mkdir($rootPath . $userFloder);

            $t['zswh'] = 'zswh_' . md5($group_id);       // 掌上武汉手机端
            $t['whtvm'] = 'whtvm_' . md5($group_id);      // 黄鹤TV手机端
            $t['zswhwc'] = 'zswhwc_' .  md5($group_id); // 掌上武汉写COOKIE
            $t['whtv'] = 'whtv_' .  md5($group_id);      // 黄鹤TV PC端
            $t['videoplay'] = 'videoplay_' .  md5($group_id); // PC端播放页面
            $t['comment'] = 'comment_' .  md5($group_id);  // PC端评论页面   

            //$t['cym'] = 'comment_' .  $group_id;      //畅言评论
            // $t['tv'] = 'tv_' .  md5($group_id);

            foreach($t as $k => $v) {
                $htmlfile = $userFloder . '/' . $v;
                $htmlpath = $rootPath;
                // $templateFile = './Application/Mapi/View/Live/' . $k . '.html';
                if($k == 'zswhwc') {
                    $this->assign('filename', 'http://plive.appwuhan.com/' . $userFloder . '/' . $t['zswh'] . '.html');    
                }
                
                $content  = $this->fetch("Mapi@Live/".$k);
                $htmlpath = !empty($htmlpath) ? $htmlpath : $rootPath;
                $htmlfile =  $htmlpath . $htmlfile . '.html';

                if(!is_dir(dirname($htmlfile)))
                    // 如果静态目录不存在 则创建
                    @mkdir(dirname($htmlfile));
                if(false === file_put_contents($htmlfile,$content))
                    throw_exception(L('_CACHE_WRITE_ERROR_').':'.$htmlfile);
            }
        }

    }

}